#ifndef LINKEDLISTH
#define LINKEDLISTH

#include <string>
#include "Collection.h" //virtual class (with virtual member functions, no data members, everything is in public)
#include "Node.h" //a linked list is made up of several Nodes
#include "LinkedListException.h"

//class to create-edit-view a linked-list of Node* objects
class LinkedList:public Collection
{
	public:
		//CONSTRUCTOR-DESTRUCTOR
		LinkedList(); //constructor
		virtual ~LinkedList(); //destructor
		LinkedList(Collection* other); //copy constructor
		
		
		//READING INFO FROM THE LIST
		virtual bool isEmpty() const; 	//tells it the list has no elements
		virtual int size() const; 	//returns the number of elements
		virtual int search(int element); //returns the index of an element in the list or -1 if element not found
		
		//MODIFYING THE LIST
		virtual void clear(); 			//clears the list from all its elements
		virtual void add(int value);		//adds an element with value VALUE to the end of the list
		virtual void add(int index,int element);//inserts element with value ELEMENT at position INDEX in the list
		virtual void addAll(Collection* c);
   
   // Inserts all of the elements in the specified collection into this
   // collection at the specified position
		virtual void addAll(int index, Collection* c);
   
   
   // Returns true if this collection contains the specified element.
		virtual bool contains(int element);
   
   // Returns the element at the specified position in this collection.
		virtual int get(int index);
   
   
   // Removes the element at the specified position in this collection
		virtual void remove(int index);
   
   // Removes from this collection all the elements that are contained in the
   // specified collection
		virtual void removeAll(Collection* c);
      
   // Returns an array containing all of the elements in this list in proper
   // sequence
		virtual int* toArray();
		
		//-----methods not present in base class Collection------
		void print(); //displays the elements in the list nicely
		LinkedList& operator=(LinkedList& other); //copies(clone) all the elements of one list into ourselves
		
		void enableDebug(); void disableDebug(); //enable and disable debug
	
	//protected here because we want the functions in this class to keep working in any inheriting class !
	//the attributes & methods here will become private in the public-inheriting class (the Stack class)
	protected:
		Node* firstNode; 		//pointer to the first node in the list 
				//(note: this variable replaces & is the same as the usual Node* ptr)
		Node* lastNode; //pointer to the last note of the list
		int Size; 			//nb of elements
		Node* nodeAt(int index);		//returns the node at INDEX or NULL if index is not correct or list empty
			//this function is put here because we don't want people to change the "next" attribute of the returned node so easily (this next parameter is used to by the linked list functions to browse through)
		bool useDebug;
};



#endif
